package com.feishi.core.socket.common.lifecycle;

import com.feishi.core.analytic.assembler.BaseAssembler;
import com.feishi.core.socket.common.filter.SocketFilter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by caixq on 5/14 014.
 */
public class SocketApplication<T extends BaseAssembler> {

    private Map<String,Object> data=new HashMap<>();

    public void setAttribute(String name,Object value){
        data.put(name,value);
    }
    public Object getAttribute(String name){
        return data.get(name);
    }
    public void clearAttribute(){
        this.data.clear();
    }
    public SocketSession createSession(){
        SocketSession session = new SocketSession(this);
        return session;
    }
    List<SocketFilter<T>> filters=new ArrayList<>();
    public void addFilter(SocketFilter<T> filter){
        filters.add(filter);
    }

    public List<SocketFilter<T>> getFilters() {
        return filters;
    }

}
